<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>角色授权</title>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link href="/back/css/style.css" rel="stylesheet" type="text/css" />
	<link href="/back/css/select.css" rel="stylesheet" type="text/css" />
	
	 <script src="/back/js/jquery.js" language="JavaScript" ></script>
	<!-- 弹窗js -->
    <script src="/back/js/layer/layer.js"></script>
    <script src="/back/js/base.js"></script>
<script type="text/javascript">
		$(function(){
			//级联选择
			$('input:checkbox').click(
				function () {
					//向上级联
					if($(this).prop('checked') == true){
						$(this).parent('div').siblings('input:checkbox').prop('checked',true).parent('div').siblings('input:checkbox').prop('checked',true);
					}else{
					}	
					//向下级联
					$(this).siblings('div').children('input:checkbox').prop('checked',$(this).prop('checked')).siblings('div').children('input:checkbox').prop('checked',$(this).prop('checked'));
				}
			);	
			
			//选中已有
			$('input:checkbox').each(function(){
				var roleRightId = '<#list roleRightList as roRight >${roRight.id?c}<#if (roRight_index+1) < (roleRightList?size)>,</#if></#list>';
				var allTmpId = roleRightId.split(',');
				var val = $(this).attr('value');
				for(var i = 0; i < allTmpId.length; i++){
					if(allTmpId[i] == val){
						$(this).prop('checked', true);
						break;
					}
				}
			});
		});
	</script>
</head>
<body >
<div class="formbody" style="background-color: #D1EEEE;">
<h4>角色授权 ---${viewrole.name!''}</h4>
<form id="formPower" name="formPower" method="post">
	<div style="margin-left: 50px;">
    <#if moduleList??>
		<#list moduleList as ml>
			<#if !ml.parentId?? || (ml.parentId!0)==0>
				<div style="margin-top: 20px;">
                   &nbsp;&nbsp;<input type="checkbox" id="rightList_${ml.id?c}" name="rightList" value="${ml.id?c}" />
                   <label for="rightList_${ml.id?c}" style="cursor: pointer;"> ${ml.name!''}</label>&nbsp;&nbsp;
					<#list moduleList as mid>
						<#if ml.id?? && mid.parentId?? && (ml.id?c) == (mid.parentId?c)>
                        <div>　　|---- 
                            <input type="checkbox" id="rightList_${mid.id?c}" name="rightList" value="${mid.id?c}" />
                            <label for="rightList_${mid.id?c}" style="cursor: pointer;"> ${mid.name!''}</label>&nbsp;&nbsp;
                            <div>　　|------------	
								<#list moduleList as chi>
									<#if  mid.id?? && chi.parentId?? && (mid.id?c) == (chi.parentId?c)>
                                       <input type="checkbox" id="rightList_${chi.id?c}" name="rightList" value="${chi.id?c}" />
                                       <label for="rightList_${chi.id?c}" style="cursor: pointer;"> ${chi.name!''}</label>&nbsp;&nbsp;
									</#if>
								</#list>
                            </div><br/>
                        </div>
						</#if>
					</#list>
                </div>
			</#if>
		</#list>
	</#if>
	<input type="hidden" name="encryptionId" value="${viewrole.encryptionId!''}">
</div>
</form>
<div style="margin-left:10%; margin-top:30px;">
		<input type="button" onclick="submitForm('/admin/role/adpower','formPower');return false;"class="btn btn-primary radius" value=" 保 存 ">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" onclick="closes();" class="btn btn-defule radius" class="button" value="返回/关闭">
	</div>
	<div>&nbsp;&nbsp;</div>
</div>
</body>
</html>